//
//  CellForClickYouJiCell.m
//  SeeTheWorld
//
//  Created by dllo on 16/1/25.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "CellForClickYouJiCell.h"
#import "PCH.pch"
#import <UIImageView+WebCache.h>


#define WIDTH [UIScreen mainScreen].bounds.size.width
#define HEIGHT [UIScreen mainScreen].bounds.size.height

@interface CellForClickYouJiCell ()

@property (nonatomic, retain)UIImageView *imageView1;
@property (nonatomic, retain)UIImageView *imageView2;

@property (nonatomic, retain)UILabel *labelForContents;

@end

@implementation CellForClickYouJiCell

- (void)dealloc {
    [_imageView1 release];
    [_imageView2 release];
    [_labelForContents release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        [self createSubViews];
        
    }
    
    return self;
}

#pragma mark ** 创建子视图
- (void)createSubViews {
    
    self.labelForContents = [[UILabel alloc] init];
    self.labelForContents.numberOfLines = 0;
    self.labelForContents.font = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:self.labelForContents];
    [_labelForContents release];
    self.labelForContents.dk_textColorPicker = DKColorWithRGB(0x343434, 0xffffff);

}

/** 赋值 */
- (void)voluationToCellSubViewsWithString:(NSString *)string {
    
    self.labelForContents.text = string;
    
}

/** 自适应高度 */
- (CGFloat)heightForLabelWithDescription:(NSString *)description {
    
    CGRect rect = [description boundingRectWithSize:CGSizeMake([UIScreen mainScreen].bounds.size.width - 30, 0) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:15]} context:nil];
    
    return rect.size.height;
}

- (CGFloat)heightForCellWithDescription:(NSString *)description {
    
    CGFloat height = [self heightForLabelWithDescription:description];
    
    return 5 + height + 5;
}

#pragma mark ** 布局子视图
- (void)layoutSubviews {
    
    [super layoutSubviews];
    
    if (self.labelForContents.text) {
        
        self.labelForContents.frame = CGRectMake(10, 5, WIDTH - 20, [self heightForLabelWithDescription:self.labelForContents.text]);
        
    } else {
        
        self.labelForContents.frame = CGRectMake(0, 0, 0, 0);
        
    }
    
}







- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
